<?php
/**
 * 系統名稱: Lotto 系統
 * 檔案說明: 專案管理-修改
 * $Author$
 * $Id$
 *
 */
$intID = (int)$_data["ID"];
$arrG = getGambleDataByID($intID);
if($arrG === false){
	ErrMsgOutputHTML("Error", "", 1);
}elseif(sizeof($arrG) == 0 || $arrG["isEnd"] == 1){
	header("Location: ".basename($_SERVER["PHP_SELF"])."?op=List&GameDate=".$_data["GameDate"]);
	exit();
}

$strSQL = "select ID from `bet_BetList` where GambleID = ".$intID;
if(!$RS = @PMA_mysql_query($strSQL, $_ConnMaster)){
	@mysql_free_result($RS);
	$GLOBALS["errormessage"] = "Can not Find Data!!";
	$GLOBALS["errorhidden"] = "\nLine: ".__LINE__.",\nPage: ".__FILE__;
	ErrMsgOutputHTML("Error", "", 1);
}
if(PMA_mysql_num_rows($RS) > 0){
	@mysql_free_result($RS);
	$GLOBALS["errormessage"] = $_strCompetition["DoNotDelete"];//此期樂透已經有人下注，不能刪除！
	$GLOBALS["errorhidden"] = "\nLine: ".__LINE__.",\nPage: ".__FILE__;
	ErrMsgOutputHTML("Error", "", 1);
}
@mysql_free_result($RS);

if(DeleteSQL($intID, "bet_Gamble")){
	if(!DeleteTodayGame($intID, $_data["LottoID"]))ErrMsgOutputHTML("LoginError", "", 1);
	if(!MakeGambleFile($_data["LottoID"]))ErrMsgOutputHTML("LoginError", "", 1);
	for($i = 1; $i < sizeof($_arrBet_Type); $i++){
		if(!MakeTodayGameFile($_data["LottoID"], $i))ErrMsgOutputHTML("LoginError", "", 1);
	}
	@mysql_close($$_Conn);
	header("Location: ".basename($_SERVER["PHP_SELF"])."?op=List&GameDate=".$_data["GameDate"]);
}
ErrMsgOutputHTML("Error", "", 1);
?>